package com.xiaodu.servlet;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: dutianjie
 * @date: 2021/4/15
 * @version: v1.0.0
 * @description: 描述
 **/
@WebServlet(value = "/test/servlet", name = "myServlet1", asyncSupported = true,
        loadOnStartup = 0,
        initParams = {
        @WebInitParam(name = "param1", value = "value1")}
)
public class MyServlet1 extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("reqeust myServlet1");
        // 获取 init-param
        String param1 = getServletConfig().getInitParameter("param1");
        System.out.println("myServlet1  listener = " + getServletContext().getAttribute("myListener"));
        super.service(req, resp);
    }
}
